﻿#include "FITKPHengLEISolverIncompressible.h"
#include "FITKPHengLEIGeneralControl.h"
#include "FITKPHengLEIInFlow.h"
#include "FITKPHengLEIAbstractInFlowType.h"
#include "FITKPHengLEIInFlowTypeNondimensional.h"
#include "FITKPHengLEIFlow.h"
namespace Interface
{

    FITKPHengLEIIncompressibleSolver::FITKPHengLEIIncompressibleSolver()
    {
        this->init();
    }

    FITKPHengLEIAbsSolver::PHengLEISolverType FITKPHengLEIIncompressibleSolver::getSolverType()
    {
        //亚音速类型
        return  FITKPHengLEIAbsSolver::PHengLEISolverType::PLSubsonic;
    }

    void FITKPHengLEIIncompressibleSolver::initBoundaryTypes()
    {

    }

    void FITKPHengLEIIncompressibleSolver::initBasicInfo()
    {
		if (!_generalControl) return;

		Core::FITKParameter* addData = _generalControl->getGeneralControlAdditionalData();
		if (!addData)return;
		addData->createDoubleParameter("intervalStepFlow", 2000);
		addData->createDoubleParameter("maxSimuStep", 20000);
		addData->createDoubleParameter("intervalStepPlot", 200);
		addData->createDoubleParameter("ntervalStepForce", 1);
		addData->createDoubleParameter("intervalStepRes", 1);

		_generalControl->setGeneralControlAdditionalData(addData);
    }

    void FITKPHengLEIIncompressibleSolver::initInflow()
    {

    }

    void FITKPHengLEIIncompressibleSolver::initGridParam()
    {

    }

    void FITKPHengLEIIncompressibleSolver::initViscous()
    {

    }

    void FITKPHengLEIIncompressibleSolver::initDiscrete()
    {

    }

    void FITKPHengLEIIncompressibleSolver::initMultiGridParam()
    {

    }


	void FITKPHengLEIIncompressibleSolver::initOutputSetting()
	{
	}

	void FITKPHengLEIIncompressibleSolver::initFlow()
	{
		if (!_flow) return;
		Core::FITKParameter* addSloverName = _flow->getAdditionalSolverName();
		if (!addSloverName)return;
		QStringList solvername = { "SIMPLE","CompressibleSIMPLE","PISO" };
		addSloverName->createComboxParameter("flowSolverName", solvername, 0);

		_flow->setAdditionalSolverName(addSloverName);

		Core::FITKParameter* addInitialValue = _flow->getAdditionalInitialValue();
		if (!addInitialValue)return;
		addInitialValue->createDoubleParameter("initRho", 998.2);
		addInitialValue->createDoubleParameter("initU", 3.05);
		addInitialValue->createDoubleParameter("initV", 0);
		addInitialValue->createDoubleParameter("initW", 0);
		addInitialValue->createDoubleParameter("initP", 0);
		addInitialValue->createDoubleParameter("initMu", 0.001003);
		addInitialValue->createDoubleParameter("initRg", 296.928571);
		addInitialValue->createDoubleParameter("initP", 101325);
		addInitialValue->createDoubleParameter("refPLocate", 0);

		_flow->setAdditionalInitialValue(addInitialValue);

		Core::FITKParameter* addMomentumEquation = _flow->getAdditionalMomentumEquation();
		if (!addMomentumEquation)return;
		QStringList MomEqSolMethod = { "GaussSeidel","GMRES","Bicgstab","AMG","PCG","FlexGMRES","ILU","AMGDD","Hybrid" };
		addMomentumEquation->createComboxParameter("MomEqSolMethod", MomEqSolMethod,0);
		QStringList MomEqPrecondMethod = { "None","ILU","AMG","Euclid","LduDiag","LduDIC","LduDILU" };
		addMomentumEquation->createComboxParameter("MomEqPrecondMethod", MomEqPrecondMethod, 0);
		addMomentumEquation->createIntParameter("MomEqMaxSweep",30);
		addMomentumEquation->createDoubleParameter("MomEqIterSolvTol", 1e-8);
		addMomentumEquation->createDoubleParameter("MomEqRelaxCoeff", 0.5);

		_flow->setAdditionalMomentumEquation(addMomentumEquation);

		Core::FITKParameter* addPressurePossionEquation = _flow->getAdditionalPressurePossionEquation();
		if (!addPressurePossionEquation)return;
		QStringList PPEqSolMethod = { "GaussSeidel","GMRES","Bicgstab","AMG","PCG","FlexGMRES","ILU","AMGDD","Hybrid" };
		addPressurePossionEquation->createComboxParameter("PPEqSolMethod", PPEqSolMethod, 0);
		QStringList PPEqPrecondMethod = { "None","ILU","AMG","Euclid","LduDiag","LduDIC","LduDILU" };
		addPressurePossionEquation->createComboxParameter("PPEqPrecondMethod", PPEqPrecondMethod, 0);
		addPressurePossionEquation->createIntParameter("PPEqMaxSweep", 30);
		addPressurePossionEquation->createDoubleParameter("PPEqIterSolvTol", 1e-8);
		addPressurePossionEquation->createDoubleParameter("PPEqRelaxCoeff", 0.3);

		_flow->setAdditionalPressurePossionEquation(addPressurePossionEquation);

		Core::FITKParameter* addSurfaceFlux = _flow->getAdditionalSurfaceFlux();
		if (!addSurfaceFlux)return;
		addSurfaceFlux->createDoubleParameter("FaceFluxRelaxCoeff", 0.5);
		addSurfaceFlux->createDoubleParameter("isCalGravityVisSource", 0);
		addSurfaceFlux->createDoubleParameter("bodyForceFlag", 0);
		addSurfaceFlux->createDoubleParameter("gravityX", 0);
		addSurfaceFlux->createDoubleParameter("gravityY", -9.81);
		addSurfaceFlux->createDoubleParameter("gravityZ", 0.0);
		addSurfaceFlux->createDoubleParameter("isBoussinesqApproximation", 0);
		addSurfaceFlux->createDoubleParameter("thermalExpansionCoeff", 3.44827e-3);

		_flow->setAdditionalSurfaceFlux(addSurfaceFlux);
	}
	void FITKPHengLEIIncompressibleSolver::initCalculation()
	{
	}
}



